From the R help file for the package, you can see if by typing ??climwin in the console.
climwin is a package in R to help users detect a time period or ‘window’ over which a response variable (usually biological) is sensitive to the environment (usually climate/weather). Periods of climate sensitivity can help inform experimental design, improve species modelling or allow users to more effectively account for climate in statistical modelling. This vignette will give an introduction to the package and its basic features. The advanced vignette provides more detail on the ‘advanced’ features present within the package.
Why do we need climwin?
The characteristics of an organism are likely to change within a year (e.g. body condition, behaviour), and these will influence the way in which an organism responds to its environment at different points in time. Therefore, when we are interested in studying the effects of climate on some biological response the time period or ‘window’ over which we choose to collect climate data can strongly influence the outcome and interpretation of our results. Yet there has been a tendency in ecological research to focus on a limited number of windows, often chosen arbitrarily. For example, there has been a strong focus on the biological impacts of average spring conditions.
Without a critical comparison of different possible windows, we limit our ability to make meaningful conclusions from our research. If a biological trait displays no response to an arbitrarily chosen climate window it is difficult to determine if this is evidence of insensitivity to climate or whether the choice of time period is flawed. Even when we find a relationship between climate and the biological response, we cannot be sure that we have selected the period where the trait is most sensitive. Therefore, there is a need for a more effective method through which we can select our sampling period.
Realistically, manually testing and comparing all possible windows can be difficult and time consuming. With climwin we hope to overcome this problem by employing exploratory approaches to test and compare the effects of all possible climate windows. This will remove the need to arbitrarily select climate windows, and will consequently improve our research outcomes and conclusions. Below we will outline the basic features of the climwin package, including how to carry out and interpret a climate window analysis.
For example, Alpine chamois have been showing a marked body mass decrease. In this paper we used 27 years of data on body mass of 1.5-year-old chamois to identify over which window the body mass was most likely affected by weather. We investigated windows of different length between the time of body mass measurement and ca. 2 years before.
Figure 3: Example from Masoero et al. 2024
# install the missing packages
install.packages("dplyr")
install.packages("lubridate")
install.packages("climwin")
# data manipulation
library(dplyr)
library(lubridate)
# models
library(lme4)
library(lmerTest)
library(climwin)
# graphics
library(ggplot2)
knitr::opts_chunk$set(
fig.path = "Figures/"
)
# loading the datasets
data_nestlings <- read.csv("Data/data_nestlings.csv",
stringsAsFactors = TRUE, na = c("", "NA")
)
data_weather <- read.csv("Data/data_clim.csv",
stringsAsFactors = TRUE, na = c("", "NA")
)
Study system
Data were collected between 1999 and 2023 in a Swiss population of Alpine swift. It is a long-distance migratory bird that breeds in colonies of a few to several hundred pairs in holes within cliffs or under the roofs of tall buildings. In Switzerland, Alpine swifts return to their breeding grounds from sub-Saharan Africa at the beginning of April (Meier et al. 2020) and start laying eggs between early May and June, with significant adaptive variations in laying dates depending on weather conditions (de Villemereuil et al. 2020). Females lay one clutch a year, with one to four eggs per clutch (modal clutch size is three). Both parents incubate the eggs for about 18 days and then feed their nestlings until fledging, which occurs around 55 days after hatching (range 50-76 days; (Bize et al. 2004) and this manuscript). After breeding, Alpine swifts migrate back to Africa in September (Meier et al. 2020).
Fieldwork was carried out in two Alpine swift colonies located in clock towers in the Swiss cities of Biel (60-100 breeding pairs) and Solothurn (40-55 breeding pairs), ca. 20km apart. Each year, both colonies were regularly visited to monitor egg laying and clutch size, to capture and measure adults, and to ring and measure nestlings. Nestlings were individually recognised by ringing them with numbered metal rings 10 to 15 days after hatching. Nestlings were measured regularly (usually every 5 to 10 days, on average five times in total) until fledging. At each measurement, we measured wing length with a ruler to the nearest 1 mm, sternum size with a calliper to the nearest 0.1 mm, and body mass with a digital scale to the nearest 0.1 g. The measure of sternum length provides an estimate of skeletal growth and size. Tarsus length has been commonly used in passerines, but it is difficult to measure in a repeatable way in a species with short and bulky tarsi, such as swifts. As nestlings are not ringed at hatching, the age of the nestlings in a brood is based on the hatching date of the first nestling; the last nestling is usually born on the same day or 1 day later. Therefore, measurements for a brood of three nestlings, for example, are taken when the first-hatched nestling reaches 50 days of age, the youngest one might be the same age or 1 day younger. Only nestlings that survived up to fledging were included in the statistical analyses. Sample sizes differ between traits, as wing length and body mass have been measured since 1999, while sternum length has been measured since 2003.
The figure below shows how the measures are collected.
A - Wing length is measured using a ruler specific for bird ringing with a bended part on one side to avoid movements of the wing. Data is recorded to the closest millimeter.
B - Tail length is measured using a thin ruler positioned between the two outermost tail feathers. Data is recorded to the closest millimeter. Both sides are measured and the average is used for the analyses.
C - Sternum length is measured using a calliper. Breast feathers are kept open using cotton and ethanol. Calliper is positioned just above the belly on the lowest part of the sternum bone and then closed on the highest part of the sternum bone, close to the head. Data is recorded to the closest tenth of a millimeter.
D - Body mass is measured using a kitchen scale. Data is recorded to the closest tenth of a gram.
Figure 2: Measurement of the Alpine swifts: wing (A), tail (B), sternum (C), body mass (D). Drawings by Martina Cadin.
Figure 3: Growth of Alpine swifts nestlings.
str(data_nestlings)
## 'data.frame': 1655 obs. of 9 variables:
## $ year : int 2002 2002 2002 2002 2003 2003 2003 2003 2003 2003 ...
## $ colony : Factor w/ 1 level "Solothurn": 1 1 1 1 1 1 1 1 1 1 ...
## $ nestcode_rearing: Factor w/ 775 levels "BT1999A1","BT1999A22",..: 96 96 95 95 142 142 142 155 155 155 ...
## $ ring : Factor w/ 1655 levels "ring_000003",..: 1094 189 883 1404 1069 1048 1350 158 295 174 ...
## $ date_hatch : Factor w/ 342 levels "01/06/03","01/06/04",..: 331 331 331 331 333 333 333 333 333 333 ...
## $ mass_50 : num 106.2 97.9 105 111.3 119.7 ...
## $ wing_50 : num 210 208 211 213 228 ...
## $ sternum_50 : num 41.2 37.8 40.6 41.5 41.5 40.8 40.3 39.8 40.5 39.5 ...
## $ brood_size : int 2 2 2 2 3 3 3 3 3 3 ...
summary(data_nestlings)
## year colony nestcode_rearing ring date_hatch mass_50 wing_50 sternum_50 brood_size
## Min. :1999 Solothurn:1655 BT1999C13: 3 ring_000003: 1 14/06/17: 26 Min. : 63.10 Min. :151.0 Min. :30.50 Min. :1.000
## 1st Qu.:2005 BT1999F36: 3 ring_000010: 1 04/06/09: 20 1st Qu.: 90.65 1st Qu.:209.0 1st Qu.:38.70 1st Qu.:2.000
## Median :2011 BT1999H41: 3 ring_000012: 1 27/05/11: 19 Median : 96.60 Median :216.0 Median :39.60 Median :3.000
## Mean :2011 BT2000A72: 3 ring_000013: 1 06/06/09: 18 Mean : 96.02 Mean :213.4 Mean :39.54 Mean :2.698
## 3rd Qu.:2017 BT2000B34: 3 ring_000016: 1 08/06/14: 17 3rd Qu.:102.30 3rd Qu.:221.0 3rd Qu.:40.50 3rd Qu.:3.000
## Max. :2023 BT2000D96: 3 ring_000017: 1 06/06/03: 16 Max. :127.30 Max. :237.0 Max. :44.00 Max. :4.000
## (Other) :1637 (Other) :1649 (Other) :1539 NA's :177
str(data_weather)
## 'data.frame': 9131 obs. of 5 variables:
## $ year : int 1999 1999 1999 1999 1999 1999 1999 1999 1999 1999 ...
## $ date : Factor w/ 9131 levels "01/01/00","01/01/01",..: 25 325 625 925 1225 1525 1825 2125 2425 2725 ...
## $ t_daily_mean : num -0.6 -0.04 5.16 7 3.96 1.3 4.48 6.56 3.08 1.08 ...
## $ rain_daily : num 0 4 3 1.2 0 0 0.4 9.55 1.4 0 ...
## $ wind_daily_mean: num 0.82 1.02 4.78 2.08 0.98 1.04 3.22 4.74 4.02 3.82 ...
summary(data_weather)
## year date t_daily_mean rain_daily wind_daily_mean
## Min. :1999 01/01/00: 1 Min. :-12.700 Min. : 0.000 Min. : 0.380
## 1st Qu.:2005 01/01/01: 1 1st Qu.: 3.820 1st Qu.: 0.000 1st Qu.: 1.180
## Median :2011 01/01/02: 1 Median : 9.960 Median : 0.050 Median : 1.700
## Mean :2011 01/01/03: 1 Mean : 9.897 Mean : 2.898 Mean : 2.067
## 3rd Qu.:2017 01/01/04: 1 3rd Qu.: 16.045 3rd Qu.: 3.000 3rd Qu.: 2.590
## Max. :2023 01/01/05: 1 Max. : 27.340 Max. :77.660 Max. :10.600
## (Other) :9125
To estimate the weather conditions during nestling development, we used meteorological data collected from five Swiss meteorological stations surrounding Biel and Solothurn (Bern-Zollikofen, Cressier, Grenchen, Koppigen, Wynau). Doing so allowed us to cover the whole foraging area of the swifts (up to 30 km in a single foraging trip) (Arn-Willi 1960) and to account for microenvironmental variations (i.e., strong weather events captured by one station only). Daily weather data were averaged across the five stations to obtain two variables: mean daily temperature (average air temperature at 2 m above ground for the whole day), daily precipitation (total rainfall for that day) and wind speed (daily mean of the wind speed scalar in m/s.).